/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package client;



/**
 *
 * @author tomek
 */
public class User implements Comparable {
    private String login;
    private String email;
    private String firstName;
    private String lastName;
    private String city;
    private String birthYear;
    
    private byte status;
    private String description;
    
    public static final byte AVAILABLE = 1;
    public static final byte BUSY = 2;
    public static final byte NOTAVAILABLE = 0;
    
    
    public User(String l) {
        login = l;
        status = NOTAVAILABLE;
    }
    
    public User(String l, String e, String fn, String ln, String c, String b) {
        login = l;
        email = e;
        firstName = fn;
        lastName = ln;
        city = c;
        birthYear = b;
        status = NOTAVAILABLE;
    }
    
    
    public String present() {
        if (!login.equals("null")) {
            return login;
        }
        else return (firstName + " " + lastName);
    }
    
    public byte getStatus() { return status; }
    public String getDescription() { return description; }
    public String getFullDetails() {
        return login+";"+email+";"+firstName+";"+lastName+";"+city+";"+birthYear+"$";
    }
    
    public void setStatus(byte s) { status = s; }
    public void setDescription(String d) { description = d; }
    

    public int compareTo(Object u) {
        
        String s1 = this.present();
        String s2 = ((User)u).present();
      
        if (((User)this).getStatus() < ((User)u).getStatus()) return 1;
        else if (((User)this).getStatus() == ((User)u).getStatus()) return s1.compareToIgnoreCase(s2);
        else return -1;        
    }
}
